package be.dch.exceptions;

public class ValidationException extends Exception {

    private static final long serialVersionUID = 8220181299962883314L;

    private static final String ERROR_OCCURED = "";

    private transient String errorkey;

    /**
     * Constructs an <code>InvalidParameterException</code> with no detail
     * message.
     */
    public ValidationException() {
	super();
    }

    /**
     * Constructs an <code>InvalidParameterException</code> with the specified
     * detail message.
     * 
     * @param messge
     *            the detail message.
     */
    public ValidationException(final String message) {
	super(message);
    }

    /**
     * Constructs an <code>InvalidParameterException</code> with the specified
     * detail message.
     * 
     * @param message
     *            the detail message.
     * @param key
     *            i18n translation key
     */
    public ValidationException(final String message, final String key) {
	super(message);
	this.errorkey = key;
    }

    /**
     * Constructs a new exception with the specified detail message and cause.
     * 
     * <p>
     * Note that the detail message associated with <code>cause</code> is
     * <i>not</i> automatically incorporated in this exception's detail message.
     * 
     * @param message
     *            the detail message (which is saved for later retrieval by the
     *            {@link Throwable#getMessage()} method).
     * @param cause
     *            the cause (which is saved for later retrieval by the
     *            {@link Throwable#getCause()} method). (A <tt>null</tt> value
     *            is permitted, and indicates that the cause is nonexistent or
     *            unknown.)
     */
    public ValidationException(final String message, final Throwable cause) {
	super(message, cause);
    }

    /**
     * Constructs a new exception with the specified cause and a detail message
     * of <tt>(cause==null ? null : cause.toString())</tt> (which typically
     * contains the class and detail message of <tt>cause</tt>). This
     * constructor is useful for exceptions that are little more than wrappers
     * for other throwables (for example,
     * {@link java.security.PrivilegedActionException}).
     * 
     * @param cause
     *            the cause (which is saved for later retrieval by the
     *            {@link Throwable#getCause()} method). (A <tt>null</tt> value
     *            is permitted, and indicates that the cause is nonexistent or
     *            unknown.)
     */
    public ValidationException(final Throwable cause) {
	super(cause);
    }

    /**
     * 
     * @return
     */
    public String getErrorkey() {
	String result = this.errorkey;
	if (this.errorkey == null) {
	    result = ValidationException.ERROR_OCCURED;
	}
	return result;
    }

}
